package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.dao.NodeDao;
import com.itheima.entity.Node;
import com.itheima.entity.dto.NodeDto;
import com.itheima.entity.vo.PageVo;
import com.itheima.service.NodeService;
import com.itheima.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 点位业务层实现类
 *
 * @Author: LiJinLong
 * @Date: 2022-08-17  14:28
 * @Description:
 */
@Service
public class NodeServiceImpl extends ServiceImpl<NodeDao, Node> implements NodeService {
    @Autowired
    NodeDao nodeDao;
    @Autowired
    RegionService regionService;

    @Override
    public PageVo<Node> seleteByPage(Long pageIndex, Long pageSize, Long regionId) {
        Page<Node> nodePage = new Page<>(pageIndex, pageSize, regionId);
        LambdaQueryWrapper<Node> queryWrapper = new LambdaQueryWrapper<>();
        Page<Node> selectPage = nodeDao.selectPage(nodePage, queryWrapper);


        PageVo<Node> pageVo = new PageVo<>();
        pageVo.setTotalPage(nodePage.getTotal());
        pageVo.setPageSize(pageSize);
        pageVo.setPageIndex(pageIndex);
        pageVo.setTotalPage(selectPage.getTotal());
        pageVo.setCurrentPageRecords(selectPage.getRecords());
        pageVo.setTotalCount(pageVo.getTotalCount());
        return pageVo;
    }

    @Override
    public NodeDto<Node> selectPage(NodeDto nodeDto) {
        Page<NodeDto> nodeDtoPage = new Page<>();
        return null;
    }
}
